/**
 * Author : wang885298.
 * Date   : 2018/6/19.
 * File   : filters.
 */

/**
 * 判断文件类型
 * @param val
 * @returns {string}
 */
function fileType (val) {
  let file = val.substring(val.lastIndexOf('.') + 1).toLowerCase()
  let type = ''
  switch (file) {
    case 'avi':
    case 'dat':
    case 'mkv':
    case 'flv':
    case 'vob':
    case 'wmv':
    case 'asf':
    case 'asx':
    case 'rm':
    case 'rmvb':
    case 'mp4':
    case '3gp':
    case 'mov':
    case 'm4v':
      type = 'mp4'
      break
    case 'ppt':
    case 'pptx':
    case 'doc':
    case 'docx':
    case 'pdf':
      type = 'office'
      break
    case 'jpg':
    case 'jpeg':
    case 'png':
    case 'bmp':
    case 'gif':
      type = 'pic'
      break
  }
  console.log('leixing', type)
  return type
}
/**
 * 判断显示三条
 */
function showThree (val) {
  if (val.length > 3) {
    return val.slice(0, 3)
  }
}

export {
  fileType,
  showThree
}
